<template>
  <div class="welcome-container">
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span>欢迎使用教务管理系统，管理员 {{ adminName }}！</span>
        </div>
      </template>
      <div class="welcome-content">
        <p>请在左侧菜单栏中选择需要管理的功能模块。</p>
        <el-divider />
        <p>当前时间: {{ currentTime }}</p>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { useAuthStore } from '@/stores/authStore'

const authStore = useAuthStore()
const adminName = ref(authStore.currentUser?.username || '')
const currentTime = ref(new Date().toLocaleString())
let timer = null

onMounted(() => {
  timer = setInterval(() => {
    currentTime.value = new Date().toLocaleString()
  }, 1000)
})

onUnmounted(() => {
  if (timer) {
    clearInterval(timer)
  }
})
</script>

<style scoped>
.welcome-container {
  padding: 20px;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.box-card {
  width: 70%;
  text-align: center;
}
.card-header {
  font-size: 24px;
  font-weight: bold;
}
.welcome-content p {
  font-size: 16px;
  line-height: 1.8;
  color: #606266;
}
.stats-row {
  margin-top: 30px;
}
</style>

